﻿/*获取党代表list*/

using System.Collections.Generic;
using System.Data;
using System;

namespace ZHDJ.MobileInterface
{
    public partial class GetXHPartyRepresentativeList : AbstractBasePage
    {
        protected override OutParam BusinessProcess<InParam, OutParam>(InParam inParam)
        {
            // 业务逻辑返回的响应对象  
            XHPartyRepresentativeOutParam result = new XHPartyRepresentativeOutParam();
            XHPartyRepresentativeInParam param = new XHPartyRepresentativeInParam();
            string logMsg = "";
            bool isFlag = true;

            try
            {
                param = inParam as XHPartyRepresentativeInParam;
                if (param.page_no * param.page_count <= 0)
                {
                    result.code = "0";
                    result.desc = "当前页,以及页记录条数必须为大于0的正整数";

                    isFlag = false;
                }

                if (isFlag)
                {
                    DataSet ds = InterfaceHelper.GetXHPartyRepresentativeList(param.page_no, param.page_count,param.BranchID);
                    if (ds != null && ds.Tables.Count == 2)
                    {
                        XHPartyRepresentative itemTemp;
                        result.data.total_pages = CommonUtils.GetTotalPages(Convert.ToInt32(ds.Tables[0].Rows[0][0]), param.page_count);
                        foreach (DataRow dr in ds.Tables[1].Rows)
                        {
                            itemTemp = new XHPartyRepresentative();
                            itemTemp.UserName = dr["UserName"].ToString();
                            itemTemp.Deputy = dr["LoginID"].ToString();
                           // itemTemp.BranchID = dr["BranchID"].ToString();
                            itemTemp.DeputyTypeName = dr["DeputyTypeName"].ToString();
                            itemTemp.Image_url = dr["ImageUrl"].ToString();
                            if (!string.IsNullOrEmpty(itemTemp.Image_url))
                                itemTemp.Image_url = CommonUtils.AppAddress + SXT.Utility.FileServer.QueryFileUrl(itemTemp.Image_url);
                            result.data.list.Add(itemTemp);
                        }
                    }
                }
                logMsg = result.desc;
            }
            catch (Exception ex)
            {
                result.code = "0";
                result.desc = "操作异常，多次出现请联系管理员";
                logMsg = ex.Message + ":" + ex.StackTrace;
            }

            CommonUtils.InsertMobileInterfaceLog(SystemCode + "-GetXHPartyRepresentativeList", SerializeHelper.JsonSerializer<XHPartyRepresentativeInParam>(param), logMsg);
            return result as OutParam;
        }

        protected void Page_Load(object sender, System.EventArgs e)
        {
            if (string.Compare(Request.QueryString["Safe"], "False", true) == 0)
                ProcessRequest<XHPartyRepresentativeInParam, XHPartyRepresentativeOutParam>();
            else
                SafeProcessRequest<XHPartyRepresentativeInParam, XHPartyRepresentativeOutParam>();
        }
    }

    #region 请求参数
    public class XHPartyRepresentativeInParam
    {
        /// <summary>
        ///	当前页
        /// </summary>
        public int page_no
        { get; set; }
        /// <summary>
        ///	页记录条数
        /// </summary>
        public int page_count
        { get; set; }
        /// <summary>
        /// 组织ID
        /// </summary>
        public string BranchID
        { get; set; }
    }
    #endregion


    #region 结果参数
    public class XHPartyRepresentativeOutParam
    {
        public XHPartyRepresentativeOutParam()
        {
            code = "1";
            desc = "操作成功";
            data = new XHPartyRepresentativeList();
        }

        /// <summary>
        /// 返回结果 具体见接口返回对照码 1	成功 0	失败 2	请求非法 加密结果和传入的MD5字符串进行比较，如果相同则执行接口操作，否则返回1001错误响应码
        /// </summary>
        public string code
        { get; set; }

        /// <summary>
        /// 结果描述 成功和失败都需要
        /// </summary>
        public string desc
        { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public XHPartyRepresentativeList data
        { get; set; }
    }

    public class XHPartyRepresentativeList
    {
        public XHPartyRepresentativeList()
        {
            total_pages = 0;
            list = new List<XHPartyRepresentative>();
        }

        public List<XHPartyRepresentative> list { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int total_pages
        { get; set; }
    }

    /// <summary>
    /// 
    /// </summary>
    public class XHPartyRepresentative
    {
        /// <summary>
        ///	代表姓名
        /// </summary>
        public string UserName
        { get; set; }
        /// <summary>
        ///	代表ID
        /// </summary>
        public string Deputy
        { get; set; }
        /// <summary>
        ///	组织ID
        /// </summary>
        //public string BranchID
        //{ get; set; }
        /// <summary>
        ///	代表类型
        /// </summary>
        public string DeputyTypeName
        { get; set; }
        /// <summary>
        ///	图片
        /// </summary>
        public string Image_url
        { get; set; }
    }
    #endregion 
}